using Godot;
using System;

public partial class GameStartButton : Area2D
{
	[Export]
	public Sprite2D[] buttons { get; set; }
	[Signal]
	public delegate void startFightSignalEventHandler();
	private bool tag = true;
	private bool indoor = false;

	public override void _Ready()
	{
		MouseEntered += OnBodyEntered;
		MouseExited += OnBodyExited;
	}
	public void OnBodyEntered()
	{
		indoor = true;
	}
	public void OnBodyExited()
	{
		indoor = false;
	}
	public override void _Input(InputEvent @event)
	{
		if (@event is InputEventMouseButton mouseEvent &&
			mouseEvent.ButtonIndex == MouseButton.Left)
		{
			if (mouseEvent.Pressed)
			{
				if (indoor)
				{
					if (tag)
					{
						buttons[0].Visible = false;
						buttons[1].Visible = true;
						tag = !tag;
						EmitSignal(SignalName.startFightSignal);
					}
					else
					{

					}

				}
			}
		}
	}

	public void endOfRoundSignalHandler(int stages)
	{
		if (stages == 1)
		{
			buttons[1].Visible = false;
			buttons[0].Visible = true;
			tag = !tag;
		}
	}
}
